/*
    Quaxx - Just another ataxx clone
    Copyright (C) 2010  Manuel Córdoba Ruiz

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>

#include "opcionesdialog.h"

OpcionesDialog::OpcionesDialog(QWidget *parent)
    : QDialog(parent)
{
	setWindowTitle("Opciones");
	j1 = new QGroupBox(tr("Jugador"));
	j2 = new QGroupBox(tr("Oponente"));
	QVBoxLayout *mainLayout = new QVBoxLayout;
	QHBoxLayout *contentLayout = new QHBoxLayout;
	QVBoxLayout *leftLayout = new QVBoxLayout;
	QVBoxLayout *rightLayout = new QVBoxLayout;
	QHBoxLayout *buttonLayout = new QHBoxLayout;

	j1_label_color = new QLabel(tr("Color ficha:"));

	j1_color = new QComboBox();
	j2_color = new QComboBox();
	j2_tipo = new QComboBox();
	

	j1_color->addItem("Rojo");
	j1_color->addItem("Verde");
	j1_color->addItem("Azul");
	j1_color->addItem("Amarillo");
	j1_color->addItem("Negro");
	j1_color->addItem("Blanco");

	j2_tipo->addItem("Humano");
	j2_tipo->addItem("Ordenador");


	j2_color->addItem("Rojo");
	j2_color->addItem("Verde");
	j2_color->addItem("Azul");
	j2_color->addItem("Amarillo");
	j2_color->addItem("Negro");
	j2_color->addItem("Blanco");


	aceptarButton = new QPushButton(tr("&Aceptar"));
	cancelarButton = new QPushButton(tr("&Cancelar"));
	connect(cancelarButton, SIGNAL(clicked()), this, SLOT(close()));
	connect(aceptarButton, SIGNAL(clicked()), this, SLOT(aceptarClicked()));
	connect(aceptarButton, SIGNAL(clicked()),this, SLOT(close()));

	buttonLayout->addWidget(aceptarButton);
	buttonLayout->addWidget(cancelarButton);

	leftLayout->addWidget(j1_label_color);
	leftLayout->addWidget(j1_color);



	j2_label_color = new QLabel(tr("Color ficha:"));
	j2_label_tipo = new QLabel(tr("Tipo jugador:"));

	rightLayout->addWidget(j2_label_color);
	rightLayout->addWidget(j2_color);
	rightLayout->addWidget(j2_label_tipo);
	rightLayout->addWidget(j2_tipo);

	j1->setLayout(leftLayout);
	j2->setLayout(rightLayout);

	contentLayout->addWidget(j1);
	contentLayout->addWidget(j2);

	mainLayout->addLayout(contentLayout);
	mainLayout->addLayout(buttonLayout);

	setLayout(mainLayout);
	setFixedWidth(250);
	setFixedHeight(200);
	
}

void OpcionesDialog::setColorFicha(int jugador, int color){
	if(jugador==1)	j1_color->setCurrentIndex(color);
	if(jugador==2)  j2_color->setCurrentIndex(color);
}

void OpcionesDialog::setTipoOponente(int tipo){
	j2_tipo->setCurrentIndex(tipo);
}

void OpcionesDialog::aceptarClicked(){
	emit ColorFichaCambiado(1,j1_color->currentIndex());
	emit ColorFichaCambiado(2,j2_color->currentIndex());
	emit TipoOponenteCambiado(j2_tipo->currentIndex());
}



